import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt() ;
        int len = scan.nextInt() ;
        int[] array = new int[n];
        int sum = 0 ; 
        for(int i = 0 ; i  < n ; i ++){
            array[i] = scan.nextInt() ;
            sum += array[i];
        }
         int leftPrev = 0 ;
         int rightPrev = array.length - 1 ;
        for(int i = 0 ; i < len ; i ++){
            int left = scan.nextInt() - 1 ;
            int right = scan.nextInt() - 1;
            while(left > leftPrev){
                sum -= array[leftPrev++];
            }
            while(right < rightPrev){
                sum -= array[rightPrev--];
            }
            while(left < leftPrev){
                sum += array[--leftPrev];
            }
            while(right > rightPrev){
                 sum += array[++rightPrev];
            }
            System.out.println(sum);
        }
    }
}